package com.order_system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.order_system.constants.Code;
import com.order_system.entity.PayMode;
import com.order_system.entity.Product;
import com.order_system.entity.ResModel;
import com.order_system.mapper.PayModeMapper;
import com.order_system.mapper.ProductMapper;
import com.order_system.service.PayModeService;
import com.order_system.service.ProductService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 李阳
 * @since 2023-01-06
 */
@Service
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements ProductService {

    @Override
    public ResModel getList(Product product) {
        LambdaQueryWrapper<Product> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(product.getTypeId()!=null,Product::getTypeId,product.getTypeId());
        List<Product> list = list(wrapper);
        return ResModel.success(Code.SUCCESS,list);
    }

    @Override
    public Product selectById(Integer productId) {
        LambdaQueryWrapper<Product> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(true,Product::getProductId,productId);
        return getOne(wrapper);
    }
}
